﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Drawing;

namespace kwzx.Common
{
    public static class VideoUtils
    {
        /// <summary>
        /// 保存图片
        /// </summary>
        /// <param name="dwCard">要保存图片的视频号</param>
        /// <param name="lpFileName">保存图片路径</param>
        /// <param name="dwQuality">缩放比例</param>
        public static void SaveAsJpegFile(int dwCard, string lpFileName, int dwQuality)
        {
            VideoOperate.VCASaveAsJpegFile(dwCard, lpFileName, dwQuality);
        }





        public static void startMonitor(int dwCard, IntPtr px, Control ctl)
        {

            VideoOperate vid = new VideoOperate();
            bool vo = vid.open(ctl.Handle);
            if (vo)
            {
                int m_dwDevNum = VideoOperate.VCAGetDevNum();
                if (m_dwDevNum == 0)
                {
                    string msg = "VC404卡驱动程序没有安装";
                }
                else
                {
                    //new System.Threading.Thread(new System.Threading.ThreadStart(delegate
                    //{

                    //    ctl.Invoke((MethodInvoker)delegate
                    //    {
                            VideoOperate.VCAOpenDevice(dwCard, px);
                            VideoOperate.Tosdinfo.Textpoint.X =10;
                            VideoOperate.Tosdinfo.Textpoint.Y = 10;
                            VideoOperate.Tosdinfo.Timepoint.X = 10;
                            VideoOperate.Tosdinfo.Timepoint.Y = 25;
                            VideoOperate.OsdParaminfo.bTransparent = true;
                            VideoOperate.OsdParaminfo.cfBkColor = ColorTranslator.ToWin32(Color.FromArgb(0, 0, 0));
                            VideoOperate.OsdParaminfo.cfHeight = 18;
                            VideoOperate.OsdParaminfo.cfWeight = 16;
                            VideoOperate.OsdParaminfo.cfWidth = 10;
                            VideoOperate.OsdParaminfo.cfSpacing = 2;
                            VideoOperate.OsdParaminfo.cfItalic = false;
                            VideoOperate.OsdParaminfo.cfUnderline = false;
                            VideoOperate.OsdParaminfo.cfStrikeOut = false;
                            VideoOperate.OsdParaminfo.cfTextColor = ColorTranslator.ToWin32(Color.FromArgb(255, 255, 255));
                        //    bool success = VideoOperate.VCASetVidCapTextOSD(dwCard, true, "通道一", ref VideoOperate.Tosdinfo.Textpoint, ref  VideoOperate.OsdParaminfo);
                            VideoOperate.VCASetVidCapDateTimeOSDParam(ref  VideoOperate.OsdParaminfo);
                            VideoOperate.VCASetVidCapDateTimeOSD(dwCard, true, ref  VideoOperate.Tosdinfo.Textpoint);
                            VideoOperate.VCAStartVideoPreview(dwCard);

            //            });

            //        }
            //)).Start();
                }
            }

        }



    }
}
